int redPin = 9;
int greenPin = 11;
int bluePin = 10;
int duration = 200;
 
void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);  
}
 
void loop()
{
  setColor(255, 0, 0);
  delay(duration);
  setColor(0, 255, 0);
  delay(duration);
  setColor(0, 0, 255);
  delay(duration);
  setColor(255, 255, 0);
  delay(duration);
  setColor(0, 255, 255);
  delay(duration);
  setColor(255, 0, 255);
  delay(duration);
}

void setColor(int red, int green, int blue) {

  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
}